package com.eims.sls_app.fragment;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.android.volley.toolbox.RequestParams;
import com.eims.sls_app.dataaccess.CircleBean;
import com.eims.sls_app.dataaccess.CircleBean.CommentBean;
import com.eims.sls_app.dataaccess.CircleBean.SchemeinfoBean;
import com.eims.sls_app.dataaccess.CircleBean.TopicBean;
import com.eims.sls_app.dataaccess.CircleBean.SchemeinfoBean.InformationIdBean;
import com.eims.sls_app.dataaccess.utils.HttpUtils;
import com.eims.sls_app.protocol.RspBodyBaseBean;
import com.eims.sls_app.ui.AccountInformationActivity;
import com.eims.sls_app.ui.MyBaseActivity;
import com.eims.sls_app.ui.WithdrawalActivity;
import com.eims.sls_app.ui.adapter.CircleAdapter;
import com.eims.sls_app.utils.App;
import com.eims.sls_app.view.MyToast;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;

import bls.juejin.cn.R;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class TextActivity extends MyBaseActivity {
	private String TAG = "TextActivity";
	private String opt, auth, info, time, imei, crc; // 格式化后的参数

	private MyHandler mHandler;
	private MyAsynTask mMyAsynTask;
	private CircleBean circleBean;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tst);
		TextView textView = (TextView) findViewById(R.id.text);
		mHandler=new MyHandler();
		textView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				mMyAsynTask = new MyAsynTask();
				mMyAsynTask.execute();
			}
		});
	}

	class MyAsynTask extends AsyncTask<Integer, Integer, String> {

		String error = "-1";

		@Override
		protected String doInBackground(Integer... params) {
			info = "";
			opt = "97";
			time = RspBodyBaseBean.getTime();
			imei = RspBodyBaseBean.getIMEI(TextActivity.this);
			// info = RspBodyBaseBean.change_TheSun(schemeId+"", context_Sun);

			// String key = MD5.md5(App.user.getUserPass() +
			// App.MD5_key);
			String key = App.key;
			if (App.user == null) {
				crc = RspBodyBaseBean.getCrc(time, imei, key, info, "-1");
				auth = RspBodyBaseBean.getAuth(crc, time, imei, "-1");
			} else {
				crc = RspBodyBaseBean.getCrc(time, imei, key, info,
						App.user.getUid());
				auth = RspBodyBaseBean.getAuth(crc, time, imei,
						App.user.getUid());
			}

			String[] values = { opt, auth, info };
			Log.i(TAG,
					"晒单"
							+ RequestParams.convertParams(TextActivity.this,
									opt, info));
			String result = HttpUtils.doPost(App.names, values,
					App.path);
			System.out.println("晒单：" + result);
			Log.i(TAG, "晒单" + result);
			error="0";
			return error;
		}

		@Override
		protected void onPostExecute(String result) {

			mHandler.sendEmptyMessage(Integer.parseInt(result));

			super.onPostExecute(result);
		}
	}

	@SuppressLint("HandlerLeak")
	class MyHandler extends Handler {
		@Override
		public void handleMessage(Message msg) {

			switch (msg.what) {
			case 0:

				break;
			case 1:

				break;
			case -1:

				break;
			case -500:

				break;
			default:
				break;
			}
			super.handleMessage(msg);
		}

	}

}
